clear
use "Data2.dta"

*Table 3
reg W2QE age, robust 
outreg2 using a.doc, replace

reg W2QE age male c.edu  employed, robust 
outreg2 using a.doc, append

reg W2QE age male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, robust
outreg2 using a.doc, append

reg W2QE elderly, robust 
outreg2 using a.doc, append

reg W2QE elderly male c.edu  employed, robust
outreg2 using a.doc, append

reg W2QE elderly male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, robust
outreg2 using a.doc, append

reg W2QE over70, robust 
outreg2 using a.doc, append

reg W2QE over70 male c.edu  employed, robust 
outreg2 using a.doc, append

reg W2QE over70 male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, robust
outreg2 using a.doc, append

reg W2QE i.age, robust 
outreg2 using a.doc, append

reg W2QE i.age male c.edu  employed, robust
outreg2 using a.doc, append

reg W2QE i.age male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, robust
outreg2 using a.doc, append

*Figure 4
logit Y age i.employed i.male c.edu W2econ W2leftright i.W2voted i.W2HCPR_LDP c.age#i.employed c.age#i.male c.age#c.W2leftright c.age#i.W2voted c.age#i.W2HCPR_LDP c.age#c.W2econ, robust

margins, at(age=(1 2 3 4 5 6) W2HCPR_LDP=(0 1))

marginsplot, xlabel(1 "20s" 2 "30s" 3 "40s" 4 "50s" 5 "60s" 6 "70s~") xtitle(Age group) legend(order(3 "Did not vote for LDP" 4 "Voted for LDP")) plot1opt(lpattern(dash) msymbol(X)) plot2opt(lpattern(dot) msymbol(T)) title(Predicted probability of disapproving QE) ytitle(Predicted probability)


*Appendix C
tab W2QE age, col chi2 


*Appendix D1
reg W2QE age male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, cluster(PREFEC) 
outreg2 using a.doc, replace

reg W2QE elderly male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, cluster(PREFEC) 
outreg2 using a.doc, append

reg W2QE over70 male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, cluster(PREFEC)   
outreg2 using a.doc, append

reg W2QE i.age male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, cluster(PREFEC)   
outreg2 using a.doc, append

reg W2QE age male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, cluster(HRDIST) 
outreg2 using a.doc, append

reg W2QE elderly male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, cluster(HRDIST) 
outreg2 using a.doc, append

reg W2QE over70 male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, cluster(HRDIST)   
outreg2 using a.doc, append

reg W2QE i.age male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP, cluster(HRDIST)   
outreg2 using a.doc, append


*Appendix D2
local control="male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP"

ologit W2QE age `control', robust
outreg2 using a.doc, replace e(r2_p)

ologit W2QE elderly `control', robust
outreg2 using a.doc, append e(r2_p)

ologit  W2QE over70 `control', robust
outreg2 using a.doc, append e(r2_p)

ologit  W2QE i.age `control', robust
outreg2 using a.doc, append e(r2_p)

*Appendix D3
local control="male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP"

mlogit W2QE age `control', robust
outreg2 using a.doc, replace e(r2_p)

mlogit W2QE elderly `control', robust  
outreg2 using a.doc, append e(r2_p)

mlogit W2QE over70 `control', robust 
outreg2 using a.doc, append e(r2_p)

mlogit W2QE i.age `control', robust  
outreg2 using a.doc, append e(r2_p)


*Appendix D4
local control="male c.edu  employed W2econ W2leftright W2voted W2HCPR_LDP"
logit Y age `control', robust  
outreg2 using a.doc, replace e(r2_p)

logit Y elderly `control', robust  
outreg2 using a.doc, append e(r2_p)

logit Y over70 `control', robust  
outreg2 using a.doc, append e(r2_p)

logit Y i.age `control', robust  
outreg2 using a.doc, append e(r2_p)


*Appendix D, Table D5
reg W2QE age employed male c.edu W2econ W2leftright W2voted W2HCPR_LDP c.age#i.employed  c.age#i.W2HCPR_LDP c.age#c.W2econ, robust
outreg2 using a.doc, replace

reg W2QE elderly employed	male c.edu W2econ W2leftright W2voted W2HCPR_LDP i.elderly#i.employed i.elderly#i.W2HCPR_LDP i.elderly#c.W2econ, robust
outreg2 using a.doc, append

reg W2QE over70 employed male c.edu  W2econ W2leftright W2voted W2HCPR_LDP i.over70#i.employed  i.over70#i.W2HCPR_LDP i.over70#c.W2econ, robust
outreg2 using a.doc, append

logit Y age employed male c.edu W2econ W2leftright W2voted W2HCPR_LDP c.age#i.employed  c.age#i.W2HCPR_LDP c.age#c.W2econ, robust
outreg2 using a.doc, append e(r2_p)

logit Y elderly employed	male c.edu W2econ W2leftright W2voted W2HCPR_LDP  i.elderly#i.employed i.elderly#i.W2HCPR_LDP i.elderly#c.W2econ, robust
outreg2 using a.doc, append e(r2_p)

logit Y over70 employed male c.edu  W2econ W2leftright W2voted W2HCPR_LDP    i.over70#i.employed  i.over70#i.W2HCPR_LDP i.over70#c.W2econ, robust
outreg2 using a.doc, append e(r2_p)


*Appendix D, Figure D5(1)
logit Y c.age male c.edu  employed W2econ c.W2leftright W2voted i.LDP_partisan c.age#i.LDP_partisan, robust
margins, at(age=(1 2 3 4 5 6) LDP_partisan=(0 1) )
marginsplot, title(Predicted probability of disapproving QE) xlabel(1 "20s" 2 "30s" 3 "40s" 4 "50s" 5 "60s" 6 "70s~") xtitle(Age group) legend(order(1 "Others" 2 "LDP supporters") )


*Appendix D, Figure D5(2)
logit Y age i.employed i.male c.edu W2econ W2leftright i.W2voted i.W2HCPR_LDP c.age#i.employed c.age#i.male c.age#c.W2leftright c.age#i.W2voted c.age#i.W2HCPR_LDP c.age#c.W2econ, robust

margins, at(age=(1 2 3 4 5 6) W2econ=(1  3  5))
marginsplot, xlabel(1 "20s" 2 "30s" 3 "40s" 4 "50s" 5 "60s" 6 "70s~") xtitle(Age group) legend(order(4 "Economy bad" 5 "Neither bad nor good" 6 "Economy good")) plot1opt(lpattern(dash) msymbol(X)) plot2opt(lpattern(dot) msymbol(T)) plot3opt(mcolor(black) lcolor(black)) title(Predicted probability of disapproving QE) ytitle(Predicted probability)
